﻿<%@ Page Title="Trả lời thắc mắc" MasterPageFile="~/Admin/Site.Master" Language="C#"
    AutoEventWireup="true" CodeBehind="TraLoiThacMac.aspx.cs" Inherits="Transport.Admin.TraLoiThacMac" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <p>
        <b>ID:</b>
        <asp:TextBox ID="txt_HoTen" runat="server" />
        <asp:TextBox ID="txt_Email" runat="server" />
        <asp:Button ID="btn_Search" runat="server" Text="Tìm" />
    </p>
    <p>
        <b>Loại thắc mắc:</b>
        <asp:DropDownList ID="ddl_Type" runat="server" AutoPostBack="True" DataSourceID="EntityDataSource_Type"
            DataTextField="ten_loai" DataValueField="ma_loai" AppendDataBoundItems="true">
            <asp:ListItem Text="Select All" Value="-1" />
        </asp:DropDownList>
        <asp:EntityDataSource ID="EntityDataSource_Type" runat="server" ConnectionString="name=transportEntities"
            DefaultContainerName="transportEntities" EnableFlattening="False" EntitySetName="loai_thac_mac"
            EntityTypeFilter="loai_thac_mac">
        </asp:EntityDataSource>
        <b>Tình trạng:</b>
        <asp:DropDownList ID="ddl_Status" runat="server" AutoPostBack="True" DataSourceID="EntityDataSource_Status"
            DataTextField="ten_tinh_trang" DataValueField="ma_tinh_trang" AppendDataBoundItems="true">
            <asp:ListItem Text="Select All" Value="-1" />
        </asp:DropDownList>
        <asp:EntityDataSource ID="EntityDataSource_Status" runat="server" ConnectionString="name=transportEntities"
            DefaultContainerName="transportEntities" EnableFlattening="False" EntitySetName="tinh_trang_hoi_dap"
            EntityTypeFilter="tinh_trang_hoi_dap">
        </asp:EntityDataSource>
    </p>
    <div>
        <asp:GridView ID="GridView_HD" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CellPadding="4" DataKeyNames="id" CellSpacing="4" DataSourceID="EntityDataSource_HD"
            ForeColor="#333333" GridLines="None">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:TemplateField HeaderText="Chọn">
                    <ItemTemplate>
                        <asp:CheckBox ID="cb_Select" runat="server"></asp:CheckBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="id" HeaderText="ID" ReadOnly="True" SortExpression="id" />
                <asp:BoundField DataField="ho_ten" HeaderText="Họ tên" SortExpression="ho_ten" />
                <asp:BoundField DataField="email" HeaderText="Email" SortExpression="email" />
                <asp:BoundField DataField="thoi_gian" HeaderText="Thời gian" SortExpression="thoi_gian"
                    DataFormatString="{0:d}" ApplyFormatInEditMode="true" />
                <asp:TemplateField HeaderText="Loại thắc mắc">
                    <ItemTemplate>
                        <asp:DropDownList ID="ddl_uType" runat="server" DataSourceID="EntityDataSource_Type"
                            DataTextField="ten_loai" DataValueField="ma_loai" SelectedValue='<%# Bind("loai_thac_mac") %>'>
                        </asp:DropDownList>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddl_uType1" runat="server" DataSourceID="EntityDataSource_Type"
                            DataTextField="ten_loai" DataValueField="ma_loai" SelectedValue='<%# Bind("loai_thac_mac") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="noi_dung" HeaderText="Nội dung" SortExpression="noi_dung" />
                <asp:TemplateField HeaderText="Tình trạng">
                    <ItemTemplate>
                        <asp:DropDownList ID="ddl_uStatus" runat="server" DataSourceID="EntityDataSource_Status"
                            DataTextField="ten_tinh_trang" DataValueField="ma_tinh_trang" SelectedValue='<%# Bind("tinh_trang") %>'>
                        </asp:DropDownList>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddl_uStatus1" runat="server" DataSourceID="EntityDataSource_Status"
                            DataTextField="ten_tinh_trang" DataValueField="ma_tinh_trang" SelectedValue='<%# Bind("tinh_trang") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <SortedAscendingCellStyle BackColor="#FDF5AC" />
            <SortedAscendingHeaderStyle BackColor="#4D0000" />
            <SortedDescendingCellStyle BackColor="#FCF6C0" />
            <SortedDescendingHeaderStyle BackColor="#820000" />
        </asp:GridView>
        <asp:EntityDataSource ID="EntityDataSource_HD" runat="server" ConnectionString="name=transportEntities"
            DefaultContainerName="transportEntities" EnableDelete="True" EnableFlattening="False"
            EnableInsert="True" EnableUpdate="True" EntitySetName="hoi_dap" EntityTypeFilter="hoi_dap"
            Where="it.loai_thac_mac = CASE WHEN @Type = '-1' THEN  it.loai_thac_mac ELSE @Type END   
            AND it.tinh_trang = CASE WHEN @Status = '-1' THEN  it.tinh_trang ELSE @Status END">
            <WhereParameters>
                <asp:ControlParameter ControlID="ddl_Type" Type="String" Name="Type" PropertyName="SelectedValue" />
            </WhereParameters>
            <WhereParameters>
                <asp:ControlParameter ControlID="ddl_Status" Type="String" Name="Status" PropertyName="SelectedValue" />
            </WhereParameters>
        </asp:EntityDataSource>
        <asp:QueryExtender ID="qeSearch" runat="server" TargetControlID="EntityDataSource_HD">
            <asp:SearchExpression DataFields="ho_ten" SearchType="Contains">
                <asp:ControlParameter ControlID="txt_Hoten" />
            </asp:SearchExpression>
             <asp:SearchExpression DataFields="email" SearchType="Contains">
                <asp:ControlParameter ControlID="txt_Email" />
            </asp:SearchExpression>
            <asp:OrderByExpression DataField="thoi_gian" Direction="Ascending" />
        </asp:QueryExtender>
    </div>
    <p>
        <b>Cập nhật tình trạng thành đã trả lời:</b>
        <asp:Button ID="btn_Update" runat="server" Text="Thực hiện" 
            onclick="btn_Update_Click"/>
    </p>
    <asp:Panel ID="emailPanel" runat="server" DefaultButton="btn_Submit">
        <p>
            Tiêu đề mail:
            <asp:TextBox ID="txt_Subject" runat="server" Width="400px" /><br />
        </p>
        <p>
            Gửi tới:
            <asp:TextBox ID="txt_RepEmail" runat="server" Width="200px"></asp:TextBox>
        </p>
        <p>
            Nội dung:
            <asp:TextBox ID="txt_NoiDung" runat="server" TextMode="MultiLine" Rows="10" Width="400px" />
        </p>
        <p>
            <asp:Button ID="btn_Submit" runat="server" Text="Gửi" OnClick="btn_Submit_Click"
                ValidationGroup="save" />
        </p>
        <asp:Label ID="lbThongBao" runat="server" ForeColor="#FF3300"></asp:Label>
    </asp:Panel>
</asp:Content>
